<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>相对定位</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        nav {
            width: 960px;
            height: 50px;
            background-color: cadetblue;
            margin: 40px auto;
        }

        ul li {
            list-style: none;
            float: left;
            width: 120px;
            line-height: 50px;
            text-align: center;
            background-color: pink;
        }

        a:hover {
            display: block;
            width: 120px;
            height: 50px;
            background-color: brown;
            border-top: 3px solid blue;
            position: relative;
            top: -3px;
        }

        a {
            text-decoration: none;
            color: beige;
        }
        .red{width: 100px;height: 100px;background-color: red;position: relative;top: 50px;left: 50px;z-index:9;}
        .blue{width: 100px;height: 100px; background-color: blue;position: relative; z-index: 1;}
    </style>
</head>

<body>
    <nav>
        <ul>
            <li><a href="">网站链接</a></li>
        </ul>
        <ul>
            <li><a href="">网站链接</a></li>
        </ul>
        <ul>
            <li><a href="">网站链接</a></li>
        </ul>
        <ul>
            <li><a href="">网站链接</a></li>
        </ul>
        <ul>
            <li><a href="">网站链接</a></li>
        </ul>
        <ul>
            <li><a href="">网站链接</a></li>
        </ul>
        <ul>
            <li><a href="">网站链接</a></li>
        </ul>
        <ul>
            <li><a href="">网站链接</a></li>
        </ul>
    </nav>
    <div class="red"></div>
    <div class="blue"></div>
</body>

</html>